import type { CardListData,CardListParams, CardParams , CardDetail} from "@/types/card";
import { request } from '@/utils/reuqest';


export const getCardListAPI = (params:CardListParams)=>{
  return request<CardListData>('/parking/card/list','GET',params)
}

export const createCarAPI = (params:Partial<CardParams>) =>{
  return request('/parking/card','POST',params)
}

// 获取编辑月卡详情

export const getCardDetailAPI = (id:string) =>{
  return request<CardDetail>(`/parking/card/detail/${id}`)
}

/**
 * 编辑月卡
 * @param {*} data
 * @returns
 */
export const updateCardAPI = (data: Partial<CardDetail>) => {
  return request('/parking/card/edit', 'PUT', data)
}	

/**
 * 删除月卡
 * @param ids 
 * @returns 
 */
export const delCardAPI = (ids: string[]) => {
  // 批量删除时，id用逗号隔开，通过 join 方法拼接字符串
  return request(`/parking/card/${ids.join(',')}`, 'DELETE')
}	  